gh-131798: Add MATCH_SEQUENCE/MAPPING to the JIT optimizer#148124
Open
Sacul0457 wants to merge 3 commits intopython:mainfrom
Open
gh-131798: Add MATCH_SEQUENCE/MAPPING to the JIT optimizer#148124Sacul0457 wants to merge 3 commits intopython:mainfrom
MATCH_SEQUENCE/MAPPING to the JIT optimizer#148124Sacul0457 wants to merge 3 commits intopython:mainfrom
Conversation
cocolato
reviewed
Apr 7, 2026
Python/optimizer_bytecodes.c
Outdated
Comment on lines
+2075
to
+2082
| if (sym_has_type(subject)) { | ||
| PyTypeObject *type = sym_get_type(subject); | ||
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; | ||
| res = match ? sym_new_const(ctx, Py_True) : sym_new_const(ctx, Py_False); | ||
| } | ||
| else { | ||
| res = sym_new_type(ctx, &PyBool_Type); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| if (sym_has_type(subject)) { | |
| PyTypeObject *type = sym_get_type(subject); | |
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; | |
| res = match ? sym_new_const(ctx, Py_True) : sym_new_const(ctx, Py_False); | |
| } | |
| else { | |
| res = sym_new_type(ctx, &PyBool_Type); | |
| } | |
| PyTypeObject *type = sym_get_type(subject); | |
| if (type != NULL) { | |
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; | |
| res = sym_new_const(ctx, match ? Py_True : Py_False); | |
| } | |
| else { | |
| res = sym_new_type(ctx, &PyBool_Type); | |
| } |
Python/optimizer_bytecodes.c
Outdated
Comment on lines
+2086
to
+2094
| if (sym_has_type(subject)) { | ||
| PyTypeObject *type = sym_get_type(subject); | ||
| int match = type->tp_flags & Py_TPFLAGS_SEQUENCE; | ||
| res = match ? sym_new_const(ctx, Py_True) : sym_new_const(ctx, Py_False); | ||
| } | ||
| else { | ||
| res = sym_new_type(ctx, &PyBool_Type); | ||
| } | ||
| } |
| op(_MATCH_MAPPING, (subject -- subject, res)) { | ||
| if (sym_has_type(subject)) { | ||
| PyTypeObject *type = sym_get_type(subject); | ||
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; |
Member
There was a problem hiding this comment.
I also wonder if this logic will be broken by abc.register.
Contributor
Author
There was a problem hiding this comment.
Hmm I'm not too sure either. I'll try to see if I can find out more
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I hope there aren't any edge cases that I did not consider...